#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		
		ll time;
		cin>>time;
		ll d=24*3600*1000;
		time=time%d;
		time=time/1000;
		int h=time/(3600);
		time-=h*3600;
		int m=time/(60);
		time-=m*60;
		if(h<10) cout<<"0"<<h<<':';
		else cout<<h<<':';
		if(m<10) cout<<"0"<<m<<':';
		else cout<<m<<':';
		if(time<10) cout<<"0"<<time;
		else cout<<time;
		cout<<endl;
	}

	return 0;
}

